﻿using RpcCentral.Model.DB;
using RpcModel.Model;
using SqlSugarHelper;

namespace RpcCentral.DAL.Repository
{
    /// <summary>
    /// 服务指令限制
    /// </summary>
    internal class ServerDictateLimitDAL : IServerDictateLimitDAL
    {
        private IRepository<ServerDictateLimitModel> _Db;
        public ServerDictateLimitDAL(IRepository<ServerDictateLimitModel> db)
        {
            _Db = db;
        }

        public ServerDictateLimit[] GetDictateLimit(long serverId)
        {
            return this._Db.Gets(c => c.ServerId == serverId, c => new ServerDictateLimit
            {
                BucketSize = c.BucketSize,
                BucketOutNum = c.BucketOutNum,
                Dictate = c.Dictate,
                LimitNum = c.LimitNum,
                LimitTime = c.LimitTime,
                LimitType = c.LimitType,
                TokenInNum = c.TokenInNum,
                TokenNum = c.TokenNum
            });
        }
    }
}
